<template>
  <div id="gameList" class="flex">
    <div class="game_item flex" v-for="item in nowList">
      <div class="top flex">
        <div class="left">
          <div class='item1'><img :src="item.ticketImg" :alt="item.ticketName"></div>
          <div class='item2'>上期开奖</div>
        </div>
        <div class="right">
          <div class="item1">{{item.ticketName}}</div>
          <div class="item2">第17111010104期</div>
          <div class="item3">{{leftTimeCom(item.date, item)}}</div>
          <div class="item4">正在开奖</div>
        </div>
      </div>
      <div class="bottom flex">
        <a class="item" href="#/charts">开奖结果</a>
        <a class="item" href="#/charts">开奖走势</a>
        <a class="item item3" @click.stop="goTouzhu(item.path)">立即投注</a>
      </div>
    </div>
  </div>
</template>

<script>
  import leftTimer from '../../assets/leftTime'
  import playMange from '../../assets/js/playMange'
  import playCom from '../../assets/js/playComponent'
  import gamenav from './gamenav.vue'

  export default {
    data() {
      return {
//        nowList: []
      }
    },
    created() {
      let allGameList = this.$store.state.allGameList
      let qwer = JSON.parse(sessionStorage.getItem('allGameList'))
      if (allGameList.length ===0 && qwer){
        this.$store.commit('c_allGameList',qwer)
      }
    },
    computed: {
      nowList () {
        return this.$store.state.allGameList
      }
    },
    methods: {
      goTouzhu(path) {
        this.$router.push(path)
      },
      leftTimeCom(date, row) {
        row.left = leftTimer(date[0], date[1], date[2], date[3], date[4], date[5])
        let setIntervalId = setInterval(() => {
          row.left = leftTimer(date[0], date[1], date[2], date[3], date[4], date[5])
        }, 1000)
        localStorage.setItem('setInterval_id', setIntervalId)
        return row.left
      }
    },
    computed: {
    	nowList() {
    		return this.$store.state.allGameList
    	}
    },
    components: {
      "gamenav": "gamenav"
    }

  }
</script>

<style lang="less">
  #gameList {
    flex-wrap: wrap;
    justify-content: flex-start;
    background-color: #f3f3f3;
    padding: 20px;
    width: 1010px;
    margin: auto;
    .game_item {
      width: 315px;
      height: 190px;
      border: 6px solid #ccc;
      margin: 0 8px 8px 0;
      flex-direction: column;
      .bottom {
        height: 40px;
        line-height: 40px;
        .item {
          width: 33.3%;
          color: black;
          font-size: 14px;
          background-color: #e9e9e9;
          border-right: 1px solid white;
          cursor: pointer;
        }
        .item:hover {
          text-decoration: underline;
        }
        .item3 {
          background: #d32036;
          color: white;
        }
      }
      .top {
        flex: 1;
        padding: 10px;
        .left {
          width: 100px;
          .item1 {
            width: 85px;
            height: 85px;
            img {
              width: 100%;
              height: 100%;
              border-radius: 50%;
            }
          }
          .item2 {
            line-height: 40px;
            color: black;
          }
        }
        .right {
          text-align: left;
          flex: 1;
          .item1 {
            font-size: 17px;
            padding: 5px 0;
          }
          .item2 {
            font-size: 15px;
            color: #d32036;
            padding: 5px 0;
          }
          .item3 {
            padding: 5px 0;
            font-size: 16px;
          }
          .item4 {
            padding-top: 10px;
          }
        }
      }
    }
  }
</style>
